package com.cb.controller;

import com.cb.service.BookingService;
import com.jia.entity.Booking;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/booking")
public class BookingController {


    @Autowired
    private BookingService bookingService;
    /**
     * 预约操作
     * @param booking
     * @return
     */
    @PostMapping("/addBooking")
    public boolean addBooking(@RequestBody Booking booking){
        return bookingService.addBooking(booking);
    }


    /**
     * 换电操作
     * @param uid
     * @param eid
     * @param cid
     * @return
     */
    @PutMapping("/updateBooking/{uid}/{eid}/{cid}")
    public boolean updateBooking(@PathVariable("uid")Integer uid,
                                 @PathVariable("eid")Integer eid,
                                 @PathVariable("cid")Integer cid){
        return bookingService.updateState(uid,eid,cid);
    }

    @GetMapping("/checkhasbooking/{uid}/{cid}")
    public boolean checkhasbooking(@PathVariable("uid") Integer uid,
                                   @PathVariable("cid") Integer cid){
        return bookingService.checkhasbooking(uid,cid);
    }

//    @GetMapping("/findMyBooking/{uid}")
//    public Booking findMyBooking(@PathVariable("uid") Integer uid){
//        return bookingService.findmy(uid);
//    }
}
